<?php

class NoteAction extends CommonAction
{	
	public function add()
	{
		$book_id = $_POST['book_id'];
		$content = $_POST['content'];
		$title = $_POST['title'];
		$note_dao = new NoteModel();
		$note_dao->addNote($book_id, $_SESSION['user']['id'], $title, $content);
		$this->success("发表成功");
	}
	
	public function showOneNote()
	{
		$note_id = $_GET['note_id'];
		$note_dao = new NoteModel();
		$note = $note_dao->getById($note_id);
		
		$book_id = $note['book_id'];
		$book_dao = new BookModel();
		$book = $book_dao->getById($book_id);
		$this->assign("book", $book);
		
		
		$this->assign("note", $note);
		$this->display();
	}
	
	public function writeNote()
	{
		$this->assignBook($_GET['book_id']);
		$this->display();
	}
}

?>